home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / gui / gtdrag3_5.lha / gtdrag / include / libraries / gtdrag.h next >
Encoding:
C/C++ Source or Header  |  1999-07-07  |  10.0 KB  |  297 lines

  1. #ifndef LIBRARIES_GTDRAG_H
  2. #define LIBRARIES_GTDRAG_H 1
  3. /*
  4. **  $VER: gtdrag.h 3.9 (30.6.99)
  5. **  Includes Release 3.4
  6. **
  7. **  Drag&Drop with GadTools
  8. **
  9. **  Copyright ©1999 pinc Software.
  10. **  All rights Reserved.
  11. */
  12.  
  13. #ifndef EXEC_LISTS_H
  14. #include <exec/lists.h>
  15. #endif
  16.  
  17. #ifndef UTILITY_HOOKS_H
  18. #include <utility/hooks.h>
  19. #endif
  20.  
  21.  
  22. #ifndef reg
  23. #define reg(x) register __ ## x
  24. #endif
  25.  
  26.  
  27. /********************* ObjectDescription structure *********************/
  28.  
  29. /* the ObjectDescription structure describes the contents of the object
  30.  * being dragged.
  31.  */
  32.  
  33. struct ObjectDescription
  34. {
  35.   APTR   od_Object;           /* the pointer to the object */
  36.   ULONG  od_GroupID;          /* DataTypes-GroupID (see datatypes.h) */
  37.   ULONG  od_Type;             /* rough format of the object */
  38.   ULONG  od_InternalType;     /* application related type */
  39.   STRPTR od_Owner;            /* owner name or NULL if you are the owner */
  40.   APTR   od_UserData;
  41. };
  42.  
  43. /** Values for od_Type **/
  44.  
  45. #define ODT_UNKNOWN 0    /* should only be used rarely    */
  46. #define ODT_STRING 1     /* simple c-string (STRPTR)      */
  47. #define ODT_NODE 2       /* (struct Node *)               */
  48. #define ODT_IMAGENODE 4  /* (struct ImageNode *)          */
  49. #define ODT_TREENODE 8   /* (struct TreeNode *)           */
  50. #define ODT_IMAGE 16     /* (struct Image *)              */
  51. #define ODT_ICON 32      /* (struct DiskObject *)         */
  52. #define ODT_IFF 64       /* pointer to an IFF-data stream */
  53. #define ODT_LOCK 128     /* a file lock                   */
  54. #define ODT_DATATYPE 256 /* a datatype object             */
  55. #define ODT_BITMAP 512   /* (struct BitMap *)             */
  56.  
  57.  
  58. /********************* DropMessage structure *********************/
  59.  
  60. /* You receive the DropMessage structure if someone has dropped an object
  61.  * on a gadget or in a window of your application. The IAddress field of
  62.  * the IntuiMessage points to this structure.
  63.  * Remember: all fields are read-only!
  64.  */
  65.  
  66. struct DropMessage
  67. {
  68.   struct MinNode dm_Node;
  69.   struct ObjectDescription dm_Object;  /* dragged object */
  70.   struct Gadget *dm_Gadget;     /* source gadget */
  71.   struct Window *dm_Window;     /* source gadget's window */
  72.   struct Gadget *dm_Target;     /* pointer to the target gadget */
  73.   LONG   dm_SourceEntry;        /* the list position of the entry */
  74.   LONG   dm_TargetEntry;        /* dto. - may be higher than the number of entries */
  75.   ULONG  dm_Flags;
  76. };
  77.  
  78. #define DMF_DROPOVER 1          /* for treeviews */
  79.  
  80.  
  81. /** The flags for the IDCMP-MsgPort of your Window **/
  82.  
  83. #define DRAGIDCMP (LISTVIEWIDCMP | IDCMP_MOUSEBUTTONS)
  84. #define IDCMP_OBJECTDROP (IDCMP_DISKINSERTED | IDCMP_DISKREMOVED)
  85.  
  86. /* If you get a message of the IDCMP_OBJECTDROP class, someone dropped
  87.  * an object on a gadget or in a window that supports it.
  88.  * The IAddress-field of the IntuiMessage points to the DragMsg in this
  89.  * case.
  90.  */
  91.  
  92. /** a drag key qualifier **/
  93.  
  94. #define IEQUALIFIER_DRAGKEY (IEQUALIFIER_LALT | IEQUALIFIER_RALT)
  95.  
  96.  
  97. /** Tags to pass to GTD_AddGadget() (a few also for GTD_AddWindow()) **/
  98.  
  99. #define GTDA_TagBase    (TAG_USER + 0x90000)
  100.  
  101. /* describe the object */
  102.  
  103. #define GTDA_Object            GTDA_TagBase + 1   /* drag node from a non-listview */
  104. #define GTDA_GroupID           GTDA_TagBase + 2   /* Datatypes GroupID (see datatypes/datatypes.h) */
  105. #define GTDA_Type              GTDA_TagBase + 3   /* rough format of object */
  106. #define GTDA_InternalType      GTDA_TagBase + 4   /* internal type flag */
  107. #define GTDA_Mask              GTDA_InternalType  /* for compatibility */
  108. #define GTDA_Image             GTDA_TagBase + 5   /* image for dragging */
  109. #define GTDA_RenderHook        GTDA_TagBase + 6   /* render hook for listview/object */
  110. #define GTDA_ObjectDescription GTDA_TagBase + 7   /* pointer to struct ObjectDescription (contents will be copied) */
  111.  
  112. /* general use */
  113.  
  114. #define GTDA_Width         GTDA_TagBase + 8     /* width of icon (only for GTDA_RenderHook & GTDA_Images) */
  115. #define GTDA_Height        GTDA_TagBase + 9     /* height of a icon ("") */
  116. #define GTDA_NoDrag        GTDA_TagBase + 10    /* do not drag from this gadget */
  117. #define GTDA_AcceptTypes   GTDA_TagBase + 11    /* accept mask value for internal drag&drop */
  118. #define GTDA_AcceptMask    GTDA_AcceptTypes     /* for compatibility */
  119. #define GTDA_AcceptFunc    GTDA_TagBase + 12    /* function which checks for acceptance of the drag */
  120. #define GTDA_ObjectFunc    GTDA_TagBase + 13    /* callback function before a drag starts */
  121. #define GTDA_SourceEntry   GTDA_TagBase + 21    /* specifies the dm_SourceEntry field */
  122.  
  123. /* listview specials */
  124.  
  125. #define GTDA_ItemHeight    GTDA_TagBase + 14    /* height of a listview entry */
  126. #define GTDA_NoPosition    GTDA_TagBase + 15    /* no position highlighting and scrolling */
  127. #define GTDA_Same          GTDA_TagBase + 16    /* can move items inside its own list */
  128. #define GTDA_Images        GTDA_TagBase + 17    /* drags only images (listview MUST contain ImageNodes/TreeNodes) */
  129. #define GTDA_NoScrolling   GTDA_TagBase + 18    /* disables scrolling */
  130. #define GTDA_DropOverItems GTDA_TagBase + 19    /* objects are dropped over other items */
  131. #define GTDA_TreeView      GTDA_TagBase + 20    /* activate treeview specials */
  132. #define GTDA_DropBetweenItems GTDA_TagBase + 22  /* works only in conjungtion with GTDA_DropOverItems */
  133.  
  134.  
  135. /** Tags to pass to GTD_AddApp() **/
  136.  
  137. #define GTDA_InternalOnly  GTDA_TagBase + 42   /* only internal drag&drop */
  138. #define GTDA_NewStyle      GTDA_TagBase + 43   /* v3 is supported */
  139.  
  140.  
  141. /** Constants for passing to GTD_GetHook() **/
  142.  
  143. #define GTDH_IMAGE 1
  144. #define GTDH_TREE 2
  145. #define GTDH_IFFSTREAM 3
  146.  
  147. /** data for GTDH_IFFSTREAM, set Hook's h_data to this structure **/
  148.  
  149. struct IFFStreamHookData
  150. {
  151.   APTR  is_Pool;        /* a memory pool, buffer will be AllocMem()ed if NULL */
  152.   UBYTE *is_Buffer;     /* pointer to the buffer */
  153.   ULONG is_Size;        /* size of the buffer */
  154.   ULONG is_Position;    /* current stream position */
  155. };
  156.  
  157.  
  158. /********************* BOOPSI gadgets *********************/
  159.  
  160. #define BOOPSI_KIND 1000            /* GTD_AddGadget() - Type */
  161.  
  162. #define GMR_HANDLEYOURSELF (~0L)    /* GTD_HandleInput() return value */
  163.  
  164. #define GM_OBJECTDRAG   (GTDA_TagBase + 1000)    /* see structures below */
  165. #define GM_OBJECTDROP   (GTDA_TagBase + 1001)
  166. #define GM_RENDERDRAG   (GTDA_TagBase + 1002)
  167.  
  168. struct gpObjectDrag
  169. {
  170.   ULONG  MethodID;
  171.   struct ObjectDescription *gpod_Object;
  172.   struct Gadget *gpod_Source;      /* pointer to the source gadget */
  173.   struct
  174.   {
  175.     WORD X,Y;                      /* mouse coordinates */
  176.   }      gpod_Mouse;
  177. };
  178.  
  179. /* if GM_OBJECTDRAG is invoked you should return one of these values
  180.  * to report gtdrag that you could make use of it (to speed up things)
  181.  */
  182.  
  183. #define GMR_REJECTOBJECT 1
  184. #define GMR_ACCEPTOBJECT 2
  185. #define GMR_UPDATE 4               /* please update me (GM_RENDERDRAG will be invoked) */
  186. #define GMR_FINAL 8                /* store the result and do not ask again */
  187.  
  188.  
  189. struct gpObjectDrop
  190. {
  191.   ULONG  MethodID;
  192.   struct DropMessage *gpod_Message;
  193.   ULONG  gpod_Qualifier;
  194. };
  195.  
  196.  
  197. struct gpRenderDrag
  198. {
  199.   ULONG  MethodID;
  200.   struct GadgetInfo *gprd_GInfo;   /* gadget context */
  201.   struct RastPort *gprd_RPort;     /* already for use */
  202.   ULONG  gprd_Mode;                /* one of the GRENDER_xxx */
  203.   struct
  204.   {
  205.     WORD X,Y;                      /* mouse coordinates */
  206.   }      gprd_Mouse;
  207. };
  208.  
  209. #define GRENDER_HIGHLIGHT 0        /* highlight yourself */
  210. #define GRENDER_DELETE 1           /* delete all highlights */
  211. #define GRENDER_INTERIM 2          /* refreshing between two GRENDER_HIGHLIGHT */
  212.  
  213. /* You have to return TRUE if you processed the rendering yourself,
  214.  * otherwise gtdrag renders the standard highlighting.
  215.  * Returning FALSE will also let gtdrag stop sending you GM_OBJECTDRAG
  216.  * messages for the current drag.
  217.  */
  218.  
  219.  
  220.  
  221.                      /*************************/
  222. /********************* additional structures **********************\
  223. **                  **************************                    **
  224. **                                                                **
  225. ** The additional structures provide special rendering options in **
  226. ** listviews which are supported by gtdrag. The CallBack-Hooks    **
  227. ** necessary to display these are reachable via the API.          **
  228. ** See GTD_GetHook().                                             **
  229. **                                                                **
  230. \******************************************************************/
  231.  
  232.  
  233. /********************* ImageNode *********************/
  234.  
  235. /* The ImageNode structure is used to have both text and images in a listview.
  236.  * A render hook for this type is provided. It is not a must!
  237.  */
  238.  
  239. struct ImageNode
  240. {
  241.   struct ImageNode *in_Succ;
  242.   struct ImageNode *in_Pred;
  243.   UBYTE  in_Type;
  244.   BYTE   in_Pri;
  245.   STRPTR in_Name;
  246.   struct Image *in_Image;
  247. };
  248.  
  249.  
  250. /********************* Tree Structures *********************/
  251.  
  252. /* The TreeNode structure provides the possibility of displaying trees
  253.  * and images within a listview. A special tree hook is included.
  254.  */
  255.  
  256. struct TreeList
  257. {
  258.   struct MinList tl_View;
  259.   struct MinList tl_Tree;
  260. };
  261.  
  262. struct TreeNode
  263. {
  264.   struct ImageNode tn_Node;
  265.   struct MinNode tn_ViewNode;
  266.   struct MinList tn_Nodes;
  267.   ULONG  tn_DepthLines;
  268.   UBYTE  tn_Depth;
  269.   UWORD  tn_Flags;
  270.   WORD   tn_X,tn_Y;
  271.   APTR   tn_Special;
  272. };
  273.  
  274. #define TNF_NONE 0
  275. #define TNF_CONTAINER 1
  276. #define TNF_OPEN 2
  277. #define TNF_ADD 4
  278. #define TNF_REPLACE 8
  279. #define TNF_LAST 16          /* last node in group */
  280. #define TNF_STATIC 32        /* can't move node */
  281. #define TNF_NOSUBDIRS 64     /* can't create sub-directory (this flag is for you only) */
  282. #define TNF_SORT 256         /* sort by name (AddTreeNode() only) */
  283. #define TNF_HIGHLIGHTED 512  /* highlight name */
  284.  
  285.  
  286. /* from the ViewNode to the TreeNode */
  287. #define TREENODE(ln) ((struct TreeNode *)((UBYTE *)ln - sizeof(struct ImageNode)))
  288.  
  289. /* size of the knobs */
  290. #define TREEKNOBSIZE 6
  291.  
  292. /* is the mouse pointer over the tree-knob? */
  293. #define MouseOverTreeKnob(tn,h,msg) ((tn)->tn_X != -1 && (msg)->MouseX >= (tn)->tn_X && (msg)->MouseY >= (tn)->tn_Y+h && (msg)->MouseX <= (tn)->tn_X+TREEKNOBSIZE && (msg)->MouseY <= (tn)->tn_Y+TREEKNOBSIZE+h)
  294.  
  295.  
  296. #endif  /* LIBRARIES_GTDRAG_H */
  297.